package com.wwinsoft.framework.entity.system;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.wwinsoft.framework.entity.IdVersionEntity;

@Entity
@Table(name = "T_CODE")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Code extends IdVersionEntity {

    private String value;

    private String code;

    private String shortDesc;

    private CodeType codeType;

    public Code() {
    }

    public Code(String code, String value) {
        this.code = code;
        this.value = value;
    }

    @ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.LAZY)
    @JoinColumn(name = "CODE_TYPE_ID", referencedColumnName = "ID")
    @Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
    public CodeType getCodeType() {
        return codeType;
    }

    public void setCodeType(CodeType codeType) {
        this.codeType = codeType;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getShortDesc() {
        return shortDesc;
    }

    public void setShortDesc(String shortDesc) {
        this.shortDesc = shortDesc;
    }
}